<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>邮箱验证</title>
    <link rel="stylesheet" href="/sources/dist/css/common.css">
    <link rel="stylesheet" href="/sources/dist/css/personal.css">
    <link rel="stylesheet" href="/sources/dist/css/email.css">
</head>
<body>
<c:import url="/header.jsp"></c:import>
<!--中间内容-->
<section class="content" style="margin-top: 100px;">
    <div class="content_all">
        <div class="content_head">
            <ul>
                <li class="checked"><span class="icon_num icon_num_1 "></span>填写资料 <span
                        class="arrow arrow_check"></span></li>
                <li class="checked"><span class="icon_num icon_num_2 ">2</span>验证邮箱 <span
                        class="arrow arrow_check"></span></li>
                <li><span class="icon_num icon_num_2 icon_num_3">3</span>完成注册</li>
            </ul>
        </div>
        <div class="email_send">
                <span>验证邮件已发送到您的邮箱 <span class="email">${email}</span>
                    <a href="javascript:void(0);" class="change_email_text">修改邮箱</a><br>
                    请单击邮件中的链接进行验证，验证成功后即完成注册
                </span><br>
            <a href="http://www.benpig.com/mail.htm" class="send">立即验证</a>
            <br>
            <small>没收到邮件？<a href="javascript:;" onclick="resend()" id="resend">再次发送</a>
            </small>
        </div>
    </div>
    <%--</form>--%>
</section>
<c:import url="/footer.jsp"></c:import>
<div class="change_email model">
    <div class="change_email_body">
        <div class="change_email_head">
            <p>修改邮箱</p>
            <a href="javascript:;" class="close"></a>
        </div>
        <div class="new_email">
            <label>新邮箱</label>
            <input type="email" placeholder="请输入新邮箱" class="email_input" name="email" id="email">
            <p class="email_error">xxxx</p>
        </div>
        <div class="email_send_model">
            <button class="re_send_email" onclick="changeEmail('${id}','${type}')">确认修改邮箱</button>
        </div>
    </div>
</div>
<script src="/sources/dist/js/jquery.min.js"></script>
<script src="/sources/dist/js/email.js"></script>
<!--提示引入-->
<script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
<script>
    //重发邮件
    function resend() {
        var id = "${id}";
        var type = "${type}";
        var email = $(".email").text();

        $.post('/android/fillMassageAction/reSendMail', {
            id: id,
            email: email,
            type: type
        }, function (data) {
            if (data.valueOf() == "true") {
                layer.msg("发送成功", {icon: 1, time: 1000})
            } else {
                layer.msg("发送失败", {icon: 5, time: 1000})

            }
        });
    }

    /**
     * 修改邮箱
     * @param id
     */
    function changeEmail(id, type) {
        var email = $("#email").val();
        if (check(email)) {
            $.post('/android/fillMassageAction/changeEmail', {
                id: id,
                email: email,
                type: type
            }, function (data) {
                if (data.valueOf() == "true") {
                    layer.msg("修改成功", {icon: 1, time: 1000});
                    $('.email').text(email);
                    $(".model").hide();
                } else {
                    layer.msg("邮箱修改失败", {icon: 5, time: 1000})
                }
            });
        } else {
            layer.msg("你输入的邮箱格式正确", {icon: 5, time: 1000})
        }
    }

    function check(email) {
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (filter.test(email)) return true;
        else {
            return false;
        }
    }
</script>
</body>

</html>